package com.example.anpapi.entity.po.usermodel.Author;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;

@Getter
public enum AuthorLevel {
    NEWBIE("NEWBIE", "新手"),
    EXPERIENCED("EXPERIENCED", "有经验"),
    PROFESSIONAL("PROFESSIONAL", "专业");

    @EnumValue
    private final String code;

    @JsonValue
    private final String description;

    AuthorLevel(String code, String description) {
        this.code = code;
        this.description = description;
    }

    /**
     * 根据code获取枚举
     */
    public static AuthorLevel getByCode(String code) {
        for (AuthorLevel level : values()) {
            if (level.getCode().equals(code)) {
                return level;
            }
        }
        return NEWBIE;
    }

    @Override
    public String toString() {
        return this.code;
    }
}

